package com.pj.compose.ui.page.main


import androidx.compose.foundation.layout.*
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.pj.compose.NavRouters
import com.pj.compose.R
import com.pj.compose.model.TextIconEntity
import com.pj.compose.ui.compose.CommonTopBar
import com.pj.compose.ui.compose.MainGridView


@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun WidgetPage(navController: NavController) {
    val gridItems = listOf(
        TextIconEntity("Button", R.mipmap.icon_grid_button),
        TextIconEntity("Dialog", R.mipmap.icon_grid_dialog),
        TextIconEntity("Flow", R.mipmap.icon_grid_float_layout),
        TextIconEntity("BottomSheet", R.mipmap.icon_grid_bottom_sheet),
        TextIconEntity("TabSegment", R.mipmap.icon_grid_tab_segment),
        TextIconEntity("ProgressBar", R.mipmap.icon_grid_progress_bar),
        TextIconEntity(NavRouters.WIDGET_GROUP_LISTVIEW_PAGE, R.mipmap.icon_grid_group_list_view),
        TextIconEntity(NavRouters.WIDGET_TIP_DIALOG_PAGE, R.mipmap.icon_grid_tip_dialog),
        TextIconEntity(NavRouters.WIDGET_RADIUS_IMAGE_VIEW_PAGE, R.mipmap.icon_grid_radius_image_view),
        TextIconEntity(NavRouters.WIDGET_ECHART_PAGE, R.mipmap.icon_grid_webview),
        TextIconEntity(NavRouters.WIDGET_POPUPS_PAGE, R.mipmap.icon_grid_popup),
        TextIconEntity(NavRouters.WIDGET_SCROLL_TABLE_PAGE, R.mipmap.icon_grid_popup),
        TextIconEntity(NavRouters.WIDGET_MY_CANVAS_PAGE, R.mipmap.icon_theme),
//        TextIconEntity("第六页", R.drawable.ic_tab_widget),
    )
    Scaffold(
        modifier = Modifier.fillMaxSize(),
        topBar = {
            CommonTopBar(title = "控件", useBack = false)
        }) { padding ->
        Column(modifier = Modifier.padding(padding)) {
            MainGridView(items = gridItems) { position ->
                navController.navigate(gridItems[position].label)
            }
        }
    }

}

@ExperimentalMaterial3Api
@Preview
@Composable
fun WidgetPagePreview() {
    WidgetPage(navController = rememberNavController())
}

